import React from 'react';

import {connect} from 'dva'

import { ProAbstract } from 'components/Abstract'
import Title from 'components/Title'

@connect(({project}) => ({...project}))
class Indicators extends React.Component {
    static defaultProps = {
        abstractConf: {
            label: '重点指标监控', list: [
            { label: '市政工程', unit: '项', field: 'civicism', child: [{ label: '新建', field: 'build' }, { label: '在建', field: 'building' }, { label: '完成', field: 'built' }]},
            { label: '接水工程', unit: '项', field: 'connection', child: [{ label: '新建', field: 'build' }, { label: '在建', field: 'building' }, { label: '完成', field: 'built' }]},
            { label: '完成设计', unit: '项', field: 'Finished', child: [{ label: '市政', field: 'civicism' }, { label: '接水', field: 'connection' }]},
            { label: '合同签订', unit: '项', field: 'Contract', child: [{ label: '市政', field: 'civicism' }, { label: '接水', field: 'connection' }]},
            { label: '竣工验收', unit: '项', field: 'Acceptance', child: [{ label: '市政', field: 'civicism' }, { label: '接水', field: 'connection' }]},
            { label: '新建工程', unit: '项', field: 'NewProject', child: [{ label: '市政', field: 'civicism' }, { label: '接水', field: 'connection' }]},
            ]
        },
    }
  componentDidMount() {
    this.init();
  }
  init = async () => {
    await this.setDateIndicators()
  }
  // 指标
  setDateIndicators = async () => {
    await this.props.dispatch({ type: 'project/queryIndicators' });
  }
  
  render() {
    const { label, list } = this.props.abstractConf;

    const { IndicatorsResource: dataSource } = this.props
    return (
      <Title title={label}  style={{'padding': '2%'}}>
        <ProAbstract
          dataSource={dataSource}
          columns={list}
          className={'col-12'}/>
      </Title>
    )
  }
}

export default Indicators;
